package com.erp.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.erp.dao.PrivilegeDAO;
import com.erp.domain.TPrivilege;
import com.erp.dto.Privilege;

@Service(value = "privilegeService")
@Transactional
public class PrivilegeService {

	private PrivilegeDAO privilegeDAO;

	public PrivilegeDAO getPrivilegeDAO() {
		return privilegeDAO;
	}

	@Resource(name = "privilegeDAO")
	public void setPrivilegeDAO(PrivilegeDAO privilegeDAO) {
		this.privilegeDAO = privilegeDAO;
	}

	public List<Privilege> list() {
		List<TPrivilege> tPrivilegeList = new ArrayList<TPrivilege>(0);
		List<Privilege> privilegeList = new ArrayList<Privilege>(0);
		tPrivilegeList = privilegeDAO.listAll();
		// TPrivilegeList =
		// privilegeDAO.find("from TPrivilege privilege order by orderNumber asc");
		if (tPrivilegeList != null) {
			for (int i = 0; i < tPrivilegeList.size(); i++) {
				privilegeList.add(new Privilege(tPrivilegeList.get(i)));
			}
		}
		return privilegeList;
	}
}
